<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加司机页面</title>
    <link rel="stylesheet" href="../../layui-v2.6.8/layui/css/layui.css">
    <script  src="../../layui-v2.6.8/layui/layui.js"></script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>添加司机</legend>
</fieldset>
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" id="ename" required  lay-verify="required" placeholder="请输入司机的姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系方式</label>
        <div class="layui-input-block">
            <input type="text" id="ephone" required  lay-verify="required" placeholder="请输入司机的联系方式" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">工资/月</label>
        <div class="layui-input-block">
            <input type="text" id="esalary" required  lay-verify="required" placeholder="请输入司机每月的工资" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">员工岗位</label>
        <div class="layui-input-block">
            <select id="epost" lay-verify="required">
                <option value=""></option>
                <option value="0">司机</option>
<!--                <option value="1">派送员</option>-->
<!--                <option value="2">操作员</option>-->
<!--                <option value="3">分公司经理</option>-->
<!--                <option value="4">会计</option>-->
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">员工身份证号</label>
        <div class="layui-input-block">
            <input type="text" id="enumber" required  lay-verify="required" placeholder="请输入司机的身份证号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">驾驶证id</label>
        <div class="layui-input-block">
            <input type="text" id="edirverid" required  lay-verify="required" placeholder="请输入司机的驾驶证id" autocomplete="off" class="layui-input">
        </div>
    </div>
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">工作时长</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" id="emonth" required  lay-verify="required" placeholder="收件人电话" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">员工工资</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" id="esalary" required  lay-verify="required" placeholder="收件人电话" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" onclick="insert_1()">添加</button>
        </div>
    </div>
</form>
<script>
    function insert_1(){
      var $ = layui.$;
      var ename =$("#ename").val();
      var ephone =$("#ephone").val();
      var esalary =$("#esalary").val();
      var epost =$("#epost").val();
      var edirverid =$("#edirverid").val();
      var enumber =$("#enumber").val();
      console.log(ename);
      var data ={
        "ename":ename,
        "ephone":ephone,
        "esalary":esalary,
        "epost":epost,
        "edirverid":edirverid,
        "enumber":enumber,
      }
      var layer = layui.layer;
      var url ="http://localhost:8080/addEmp";
        $.ajax({
            url:url,
            type:"get",
            dataType:"json",
            async:true,
            // cache:false,
            data:data,
            success: function(data){
                console.log(data)
                if (data.code == 0) {

                    layer.msg("添加成功", {icon: 6,time:1800},function (){
                        // location.href = '../car/addCar.html';
                    });
                    window.location.href = 'carIndex.html';
                } else {
                    layer.msg("添加失败", {icon: 5});
                }
                return false;
            }
        });
    }
</script>
</body>
</html>